<?php
    // include_once(LIB_PATH.'thumb.php');
   function potting($file){

          $filesize = 1024*1024*2; //文件大小优化

        if($file['size']> $filesize){

           echo '<script>alert("您上传的文件超过允许大小");</script>';die;
        }

        $filetype = array('jpg','jpeg','png','gif','');

        $ipos = stripos($file['type'],'/');

        $type = substr($file['type'],$ipos+1);

        if(!in_array($type, $filetype)){

           echo '<script>alert("不是允许上传的文件类型");</script>';die;
}
          $filename = date('YmdHis').mt_rand(100005, 999999);

          $filename.= '.'.$type;

          $savePath = './uploads/'.date('Y-m').'/'.date('d').'/';

          if(!file_exists($savePath)){

                mkdir($savePath,777,true);
          }
        //$savePath=>  ./uploads/2017-06/01/
        //$filename=>......
        $savePathdir=$savePath;
        $savePath.=$filename;//拼接文件名

        // echo $savePathdir;die;

         move_uploaded_file($file['tmp_name'],$savePath);

         // thumb($savePath);

         //return $savePath;

         return  thumb($savePathdir,$filename);

  }